/*
 *  MWPrint.cpp
 *  T3nsors2
 *
 *  Created by Michael Barriault on 10-07-05.
 *  Copyright 2010 University of Guelph. All rights reserved.
 *
 */


#define HAVE_HDF

#include "MW.h"
#include <string>
#include <cmath>
#include <fstream>
#ifndef __APPLE__
#include <bbhutil.h>
#endif
using namespace t3;
using std::string;
using std::ofstream;
using std::endl;

void MW::Print(double t, scalar* c) {
	double *C; C = &c->at(0);
	int O[3];
	FOR(a,3) O[a] = this->O->at(a);
	double *xyz;
	xyz = new double[O[0]+O[1]+O[2]];
	FOR(i,O[0]) xyz[i] = this->x->c(0)->pt(i,0,0);
	FOR(j,O[1]) xyz[j+O[0]] = this->x->c(1)->pt(0,j,0);
	FOR(k,O[2]) xyz[k+O[1]+O[0]] = this->x->c(2)->pt(0,0,k);
	int m = int(log(c->O->at(0))/log(2));
	string pid = c->id + "_" + itos(m);
#ifndef __APPLE__
	gft_out_full((char*)pid.c_str(), t, O, (char*)"x|y|z", 3, xyz, C);
#endif
	delete[] xyz;
	return;
}

void MW::Print(double t, vector* v) {
	FOR(a,v->N) Print(t, v->c(a));
	return;
}

/*void gft_out_full(char* str, double t, int* O, char* coords, int n, double* x, double* C) {
	string tab = "\t";
	ofstream out;
	out.open(((string)str + ".dat").c_str());
	FOR(i,O[0]) {
		FOR(j,O[1]) {
			FOR(k,O[2]) {
				out << x[i] << tab << x[O[0]+j] << tab << x[O[0]+O[1]+k] << tab << C[i+j*O[0]+k*O[0]*O[1]] << endl;
			}
			out << endl;
		}
		out << endl;
	}
	out.close();
}
*/